package com.hockeo.server.data.entity;

import com.hockeo.client.model.JSData;
import com.hockeo.server.data.DAO;
import com.hockeo.server.servlet.convert.GwtEnabled;
import com.hockeo.tinygds.annotation.TEntity;
import com.hockeo.tinygds.annotation.TId;
import com.hockeo.tinygds.annotation.TName;
import com.hockeo.tinygds.annotation.TUnindexed;

/**
 * Represents a national hockey association.
 *
 * @version $Id$
 * @author jjanke
 */
@TEntity
public class Association implements GwtEnabled
{
  @TId
  private String d_strId;

  @TName( "countries" )
  @TUnindexed
  private String d_strAssociatedCountries;

  /** Argument-less constructor for TinyGDS. */
  private Association()
  {}

  @Override
  public void fromGwt( JSData strSrc )
  {
    d_strId = strSrc.getId();
    d_strAssociatedCountries = strSrc.getString( "countries" );
  }

  @Override
  public void toGwt( JSData dest, DAO dao, String strParent )
  {
    toGwtMinimal( dest, dao, strParent );
  }

  @Override
  public void toGwtMinimal( JSData dest, DAO dao, String strParent )
  {
    dest.set( JSData.PARAM_ID, d_strId );
    dest.set( "countries", d_strAssociatedCountries );
  }
}
